package example

import (
	"fmt"
	"time"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
	"github.com/jinzhu/now"
)

func Now(a fyne.App) {
	w := a.NewWindow("")
	w.Resize(fyne.NewSize(900, 600))
	var result = widget.NewMultiLineEntry()
	msg := widget.NewLabel("")
	btn := widget.NewButton("do", func() {
		time.Now() // 2013-11-18 17:51:49.123456789 Mon
		result.SetText(fmt.Sprint(
			"\n", now.BeginningOfMinute(), // 2013-11-18 17:51:00 Mon
			"\n", now.BeginningOfHour(), // 2013-11-18 17:00:00 Mon
			"\n", now.BeginningOfDay(), // 2013-11-18 00:00:00 Mon
			"\n", now.BeginningOfWeek(), // 2013-11-17 00:00:00 Sun
			"\n", now.BeginningOfMonth(), // 2013-11-01 00:00:00 Fri
			"\n", now.BeginningOfQuarter(), // 2013-10-01 00:00:00 Tue
			"\n", now.BeginningOfYear(), // 2013-01-01 00:00:00 Tue

			"\n", now.EndOfMinute(), // 2013-11-18 17:51:59.999999999 Mon
			"\n", now.EndOfHour(), // 2013-11-18 17:59:59.999999999 Mon
			"\n", now.EndOfDay(), // 2013-11-18 23:59:59.999999999 Mon
			"\n", now.EndOfWeek(), // 2013-11-23 23:59:59.999999999 Sat
			"\n", now.EndOfMonth(), // 2013-11-30 23:59:59.999999999 Sat
			"\n", now.EndOfQuarter(), // 2013-12-31 23:59:59.999999999 Tue
			"\n", now.EndOfYear(), // 2013-12-31 23:59:59.999999999 Tue
		))
	})
	top := container.NewVBox(btn)
	c := container.NewBorder(top, msg, nil, nil, result)
	w.SetContent(c)
	w.CenterOnScreen()
	w.Show()
}
